def solve(nums):
    n = len(nums)
    l = list([0] * n)
    r = list([0] * n)
    answer = []

    l[0] = 1
    for i in range(1, n):
        l[i] = l[i - 1] * nums[i - 1]

    r[n - 1] = 1
    for i in range(n - 2, -1, -1):
        r[i] = r[i + 1] * nums[i + 1]

    for i in range(n):
        answer.append(l[i] * r[i])

    return answer


if __name__ == "__main__":
    nums = [1, 2, 3, 4]
    print(solve(nums))
